home *** CD-ROM | disk | FTP | other *** search
/ PD ROM 1 / PD ROM Volume I - Macintosh Software from BMUG (1988).iso / Stacks / Updates⁄New / TEXAS for BMUG / C progs / qndxr.2 ƒ / open_files.2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-11-03  |  2.0 KB  |  79 lines  |  [TEXT/KAHL]

  1. /* functions to open files as needed in qndxr work...
  2.  */
  3.  
  4. #include <stdio.h>
  5. #include <unix.h>
  6. #include <storage.h>
  7. #include <strings.h>
  8. #include <ctype.h>
  9. #include <proto.h>
  10. #include "qndxr.2.h"
  11.  
  12. FILE *open_docfile (argc, argv) 
  13.   int argc;
  14.   char *argv[];
  15.   {
  16.     FILE *fp, *fopen();
  17.     void exit();
  18.     
  19.     if (argc < 2)
  20.       {
  21.         printf ("\nToo few command line arguments!\n");
  22.         printf ("\nEnter a text file name (no embedded spaces allowed)\n");
  23.         printf ("and the program will build and sort a complete inverted\n");
  24.         printf ("index to that file.  Use \">\" in front of a file name to\n");
  25.         printf ("redirect console output (UNIX-fashion) if desired.\n");
  26.         printf ("Give the program a value for available memory (in bytes)\n");
  27.         printf ("if the default value of 512kB is unsatisfactory ... larger\n");
  28.         printf ("memory allows for faster index building and sorting.\n");
  29.         printf ("Other command-line arguments:\n");
  30.         printf ("  \"-e\" preserves embedded punctuation\n");
  31.         printf ("  \"-a\" preserves all punctuation characters\n");
  32.         printf ("  \"-s\" preserves special (non-ASCII) characters\n");
  33.         printf ("\nContact Mark Zimmermann, 9511 Gwyndale Drive, Silver Spring\n");
  34.         printf ("Maryland  20910  USA; 301-565-2166; science (at) nems.arpa;\n");
  35.         printf ("[75066,2044] on CompuServe for further information. - ^z\n");
  36.         exit (1);
  37.       }
  38.  
  39.     if ((fp = fopen (argv[1], "r")) == NULL)
  40.       {
  41.           printf ("\nFatal error opening document file\"%s\"!\n", argv[1]);
  42.           exit (1);
  43.       }
  44.     
  45.     return (fp);
  46.   }
  47.  
  48.  
  49. /* open the key file with proper name for this pass ... file will be
  50.  * named "x0kN" where N represents the pass number ....
  51.  */
  52.  
  53. FILE *open_kfile (pass_number)
  54.   int pass_number;
  55.   {
  56.     FILE *fopen();
  57.     char fname[32];
  58.     
  59.     sprintf (fname, "x0k%d", pass_number);
  60.     return (fopen (fname, "wb"));
  61.   }
  62.  
  63.  
  64. /* open the ptr file with proper name for this pass ... file will be
  65.  * named "x0pN" where N represents the pass number ....
  66.  */
  67.  
  68. FILE *open_pfile (pass_number)
  69.   int pass_number;
  70.   {
  71.     FILE *fopen();
  72.     char fname[32];
  73.     
  74.     sprintf (fname, "x0p%d", pass_number);
  75.     return (fopen (fname, "wb"));
  76.   }
  77.  
  78.  
  79.